Skip to content

Fix for that instanceIndex is confusing in two contexts, use invocationId#32860

Open
mullicode wants to merge 4 commits intomrdoob:devfrom
mullicode:fix_instanceIndex_1_26
Open

Fix for that instanceIndex is confusing in two contexts, use invocationId#32860
mullicode wants to merge 4 commits intomrdoob:devfrom
mullicode:fix_instanceIndex_1_26

Conversation

@mullicode
Copy link

@mullicode mullicode commented Jan 27, 2026

Fixes: #32738

Description

##Problem
Currently, instanceIndex is used for two different purposes:

  • In vertex shaders: mesh instance index (WebGPU instance_index)
  • In compute shaders: global invocation index (computed from globalId)

This causes confusion because:

  • The term "instance" typically refers to geometry instancing, not compute invocations
  • It conflicts with WebGPU/Vulkan terminology, which uses "invocation" for compute shaders
  • The dual meaning makes code harder to understand and maintain
  • Documentation is unclear about when to use which meaning

##Solution
Introduced a new invocationIndex constant specifically for compute shader invocations, while keeping instanceIndex for mesh instances only. This aligns with WebGPU/Vulkan terminology and clarifies the distinction.

@github-actions
Copy link

github-actions bot commented Jan 27, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 357.49
84.84
357.49
84.84
+0 B
+0 B
WebGPU 622.1
172.81
622.44
172.94
+344 B
+135 B
WebGPU Nodes 620.7
172.57
621.05
172.66
+344 B
+98 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 490.47
119.9
490.47
119.9
+0 B
+0 B
WebGPU 693.21
188.1
693.51
188.17
+295 B
+69 B
WebGPU Nodes 642.59
175.2
642.89
175.27
+295 B
+68 B

@mullicode mullicode closed this Jan 27, 2026
@mullicode mullicode reopened this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Semantics Suggestion: instanceIndex is confusing in two contexts, use invocationId

1 participant